{% extends "base.html" %}

{% block content %}
    <h2>{{view_account.nickname}}</h2>
  {% for error in error_msg %}
    <p><strong>{{error}}</strong></p>
  {% endfor %}
  {% ifequal account.key view_account.key %}
    <form action="/accounts/rename" method="post">
      <p><input type="hidden" name="id" value="{{account.key}}" />
        <input type="textfield" name="name" value="{{account.nickname}}" />
        <input type="submit" value="Rename" />
      </p>
    </form>
  {% endifequal %}
    <br />
    <h2>Levels & Abilities</h2>
    <p>{{view_account.unit_set.count}} units available.</p>
    <h3>Level {{view_account.level}}</h3>
    <p>{{xp_msg}}</p>
    <p>{{goods_msg}}</p>
  {% ifequal account.key view_account.key %}  
    <p>Which goods would you like to use?</p>
    <form action="/accounts/view" method="post">
      <input type="hidden" name="id" value="account.key" />
  {% endifequal %}
    {% for good in view_account.goods %}
      <p>
      {% ifequal account.key view_account.key %}
        <input type="checkbox" name="goods" value="{{good.name}}"
      {% if not  good.contains_enough_for_upgrade %}
        disabled = "disabled" style="opacity:0.5"
      {% endif %}
        />
      {% endifequal %}
      <img style="background-color: white; border: 1px solid red; background-color: rgba(255,255,255,0.5); width:25px; height:25px;" src="/assets/{{good.icon}}" alt="good.name" /> :{{good.amount}}
      </p>
    {% endfor %}
    {% ifequal account.key view_account.key %}
      <input type="Submit" />
    </form>
    {% endifequal %}
    <br />
    <h2>Planets</h2>
    <div id="planets">
    {% for planet in view_account.planet_set %}
        <div class="personalPlanet">
            <div class="planetName"><a href="/planets/view?id={{planet.key}}">{{planet.name}}</a></div>
          {% if planet.is_under_attack %}
            <div class="planetStatus">Under attack by 
              <a href="/accounts/view?id={{planet.active_battle.attacker.key}}">{{ planet.active_battle.attacker.nickname}}</a>
            </div>
          {% endif %}
            <div class="ownerName">{{planet.owner.nickname}}</div>
            <div class="planetImage"><img src="/assets/{{planet.planets_icon}}" /><img class="planetResource" src="/assets/{{planet.goods_icon}}" alt="{{planet.goods_str|capfirst}}" title="{{planet.goods_str|capfirst}}" style="background-color: white; border: 1px solid red; background-color: rgba(255,255,255,0.5);" /></div>
        </div>
    {% endfor %}
    </div>
{% endblock %}